package com.zwps.biz.controller.http;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zwps.biz.api.model.vo.pubpointall.PubPointCountVO;
import com.zwps.biz.api.model.vo.structure.*;
import com.zwps.biz.dal.db.object.ZDeputyActivityRecordDO;
import com.zwps.biz.domain.service.PubPointAllService;
import com.zwps.biz.domain.service.TDepartmentService;
import com.zwps.biz.domain.service.ZDeputyActivityRecordService;
import com.zwps.biz.domain.service.ZWaterLawEnforcementService;
import com.zwps.common.controller.response.message.ResponseDataMessage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "四制（治）")
@RestController
@RequestMapping("structure/organize")
@Validated
public class TDepartmentController {

    @Autowired
    private TDepartmentService departmentService;
    @Autowired
    private ZWaterLawEnforcementService waterLawEnforcementService;
    @Autowired
    private PubPointAllService pubPointAllService;
    @Autowired
    private ZDeputyActivityRecordService deputyActivityRecordService;

    @Operation(summary = "获取水库组织架构")
    @GetMapping("getStructure")
    public ResponseDataMessage getDate() {
        return  ResponseDataMessage.data(departmentService.getDate());
    }

    @Operation(summary = "查询公司内设部门和人员")
    @GetMapping("getDepartWorker")
    public ResponseDataMessage getDepartWorker() {
        return  ResponseDataMessage.data(departmentService.getDepartWorker());
    }

    @Operation(summary = "水库资产管理统计")
    @GetMapping("getPropertyCount")
    public ResponseDataMessage getPropertyCount() {
        return  ResponseDataMessage.data(departmentService.getPropertyCount());
    }


    @Operation(summary = "部门岗位职责")
    @GetMapping("getPosition")
    public ResponseDataMessage getPosition() {
        return  ResponseDataMessage.data(departmentService.getPosition());
    }

    @Operation(summary = "水库经费落实情况")
    @GetMapping("getPay")
    public ResponseDataMessage getPay(@RequestParam Integer year) {
        return  ResponseDataMessage.data(departmentService.getPay(year));
    }


    @Operation(summary = "运行经费落实")
    @GetMapping("getFundingSituation")
    public ResponseDataMessage getFundingSituation(@RequestParam(value = "year",required = false) Integer year,@RequestParam(value = "projectType",required = false) String projectType) {
        projectType= projectType== null ? "2" :projectType;
        FundingSituationVO fundingSituationVO = new FundingSituationVO();
        fundingSituationVO.setZSalaryPayCountVO(departmentService.getPay(year));
        fundingSituationVO.setMaintainInfoVO(pubPointAllService.getMaintainInfo(year, projectType));
        return  ResponseDataMessage.data(fundingSituationVO);
    }

    @Operation(summary = "水事执法")
    @GetMapping("getWaterLawEnforcement")
    public ResponseDataMessage getWaterLawEnforcement() {

        return  ResponseDataMessage.data(waterLawEnforcementService.getWaterLawEnforcement());
    }
    @Operation(summary = "水事巡查")
    @GetMapping("getWaterLawEnforcementCount")
    public  ResponseDataMessage getWaterLawEnforcementCount(@RequestParam(value = "type",required = false) Integer type,@RequestParam(value = "year",required = false) Integer year) {

        return  ResponseDataMessage.data(waterLawEnforcementService.getWaterLawEnforcementCount(type,year));
    }

    @Operation(summary = "水事巡查统计")
    @GetMapping("getWaterLawEnforcementCountNew")
    public ResponseDataMessage getWaterLawEnforcementCounts( @RequestParam(value = "year",required = false) Integer year) {

        return  ResponseDataMessage.data(waterLawEnforcementService.getWaterLawEnforcementCounts(year));
    }
    @Operation(summary = "履职记录")
    @GetMapping("getDeputyActivityRecord")
    public ResponseDataMessage getDeputyActivityRecord(@RequestParam(value = "year",required = false) Integer year) {
        List<ZDeputyActivityRecordDO> list =departmentService.getList(year);
        return ResponseDataMessage.data(list);
    }

}
